package com.wangchao.administrator.zenmechi.ui.specialactivity;

import android.content.Context;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.wangchao.administrator.zenmechi.R;
import com.wangchao.administrator.zenmechi.base.BaseActivity;
import com.wangchao.administrator.zenmechi.bean.special.SpecialBean;

import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by My on 2016/10/19.
 */
public class SpecialActivity extends BaseActivity implements SpecialContract.View {
    @BindView(R.id.tv_title_spec)
    TextView tvTitleSpec;
    @BindView(R.id.iv_back_spc)
    ImageView ivBackSpc;
    @BindView(R.id.rela_top_spec)
    RelativeLayout relaTopSpec;
    @BindView(R.id.ptr_lv_spec)
    PullToRefreshListView ptrLvSpec;
    private SpecialContract.Presenter presenter;
    private Context context;
    private Map<String,String> urlMap;

    @Override
    public void initViews() {
        context=this;
        presenter=new SpecialPresenter(this);


    }

    @Override
    public void initData() {
        presenter.setListadpter(ptrLvSpec,this);
        ptrLvSpec.setMode(PullToRefreshBase.Mode.BOTH);

        ptrLvSpec.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
            @Override
            public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
                presenter.setListadpter(ptrLvSpec,context);
            }

            @Override
            public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
                presenter.setListadpter(ptrLvSpec,context);
            }
        });
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_special;
    }

    @Override
    public void onSuccess(SpecialBean specialBean) {

        ptrLvSpec.onRefreshComplete();


    }

    @Override
    public void onFail(Exception e) {
        ptrLvSpec.onRefreshComplete();
        Toast.makeText(this,"加载失败",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.iv_back_spc)
    public void onClick() {
        finish();
    }
}
